﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq.Mapping;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IBLL;
using DataMode;
using BLLFactory;

namespace Face.Web.xwbemo1
{
    public partial class UserInfoCheck : System.Web.UI.Page
    {
        private string WEB_PATH;
        public string THIS_DIR_PATH;
        public string savePath;
        public string thisUserName;

        UserinfoIBLL userinfoIBLL = BLLFactory.DataAccess.getUserinfoIBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userName"] != null && Session["admin"] != null)
            {
                thisUserName = (Session["userName"].ToString());
            }
            else if (Session["user"] != null)
            {
                thisUserName = (Session["user"].ToString());
            }
            else if (Session["admin"] != null)
            {
                Response.Redirect("/Admin/AdminUserManager.aspx");
            }
            else
            {
                Response.Redirect("/login_and_signup/login.aspx");
            }


            if (!IsPostBack)
            {
                Setbind();
            }
            

            
        }

        public void Setbind()
        {
            userinfo gui = new userinfo();
            string name = thisUserName;


            gui = null;
            Console.WriteLine("----------End Add a student");
            gui = userinfoIBLL.getuserinfo(name);
                tb_UserName.Text = gui.username;
                TextBox1.Text = gui.cellphone;
                TextBox2.Text = gui.email;
                //string s = gui.birthday.ToString();
                //TextBox3.Text = s;
                TextBox4.Text = gui.sex;

            savePath = gui.user_avatar;
        }

        protected void btn_logout(object sender, EventArgs e)
        {
            Session.Remove("user");
            Response.Redirect("/login_and_signup/login.aspx");
        }

    }
}